

import java.awt.*;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*;

public class FormResolucao extends JPanel {
    private final JButton botao;
    private final ArrayList<FormResposta> respostas;
    private final JScrollPane scroll;
    private final JPanel pResp;
    
    
    public FormResolucao(ActionListener control) {
        this.setLayout(new GridLayout(3,1));
        
        botao = new JButton("Terminar.");
        JPanel p = new JPanel();
        p.add(botao);
        this.add(p);
        botao.addActionListener(control);
        
        pResp = new JPanel(new GridLayout(5,1));
        respostas = new ArrayList<FormResposta>();
        scroll = new JScrollPane(pResp);
        this.setPreferredSize(new Dimension(100, 300));
        this.add(scroll, BorderLayout.CENTER);
        
        this.setVisible(true);
    }
    
    void nova(int i) {
        pResp.setLayout(new GridLayout(i,1));
        pResp.removeAll();
        respostas.clear();
        for(int n=0;n<i;n++){
            respostas.add(new FormResposta());
            pResp.add(respostas.get(n));
        }
        pResp.repaint();
    }
    
    public void setResposta(int n, String resp){
        respostas.get(n).setResposta(resp);
    }
   
}